package com.hankol.winecellar.adapter

import com.baselibrary.extension.checkValue
import com.baselibrary.extension.load
import com.baselibrary.utils.CommonUtil
import com.baselibrary.view.RoundCornerImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.winecellar.R
import com.hankol.winecellar.bean.PrivateMealManageListBean
import com.hankol.winecellar.bean.WineryCoverBean

/*私房下酒菜管理列表
* */
class PrivateMealAdapter : BaseQuickAdapter<PrivateMealManageListBean, BaseViewHolder>(R.layout.item_private_meal) {


    override fun convert(helper: BaseViewHolder, item: PrivateMealManageListBean) {
        helper.apply {
            setGone(R.id.tv_rank, adapterPosition == 0 || adapterPosition == 1 || adapterPosition == 2)
            setText(R.id.tv_rank, "TOP${adapterPosition.plus(1)}")
            val coverBean = CommonUtil.jsonToBean(item.appetizerImg.checkValue(), WineryCoverBean::class.java)
            setGone(R.id.img_video_tag, coverBean.type == 1)
            getView<RoundCornerImageView>(R.id.rimg_cover).load(mContext, if (coverBean.type == 0) coverBean.coverUrl.checkValue() else coverBean.videoUrl.checkValue())
            setText(R.id.tv_name, item.appetizerName.checkValue())
            addOnClickListener(R.id.tv_edit)
            addOnClickListener(R.id.tv_delete)
            addOnClickListener(R.id.rimg_cover)
        }
    }
}